#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Copyright (c) 2025 粤港澳大湾区（广东）国创中心

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

File: pyncti_prism.py
Desc: Function to stretch selected objects along specified vectors and distances
Author: xumanjia
Date: 2025-08-01
"""
def pyncti_prism(NCTI,doc):
    doc.ResetCaseResult()
    vec = NCTI.Vector(1, 0, 0)
    res  = doc.ReturnDialogData(-1, "拉伸","方向：", vec, "大小：", "1")
    sel  = NCTI.SelectionManager(doc)
    if len(res) == 2 and len(sel.ObjectNames) > 0:
        length = float(res[1])
        vec.X = vec.X * length
        vec.Y = vec.Y * length
        vec.Z = vec.Z * length

        if not hasattr(pyncti_prism, "counter"):
            pyncti_prism.counter = 0
        else:
            pyncti_prism.counter += 1
        resname = f"prism_obj_{pyncti_prism.counter}"
        doc.RunCommand("cmd_ncti_prism", resname, sel.ObjectNames[0], vec)